package functionOptions

import "fmt"

type ErrorHandler func(err error)
type Options struct {
	async    bool
	handler  ErrorHandler
	maxTasks int64
}
type Option func(options *Options)

type GPool struct{
	size int64
	options *Options
}

func NewGPool(size int64, opts ...Option) *GPool {
	options := loadOpts(opts)
	return &GPool{
		size: size,
		options: options,
	}
}

func loadOpts(opts []Option) *Options {
	options := &Options{}
	for _, opt := range opts{
		opt(options)
	}
	return options
}

func WithAsync(async bool) Option {
	return func(options *Options) {
		options.async = async
	}
}
func WithErrorHandler(handler ErrorHandler) Option {
	return func(options *Options) {
		options.handler = handler
	}
}
func WithMaxTasks(maxTasks int64) Option {
	return func(options *Options) {
		options.maxTasks=maxTasks
	}
}

func Do(){
	p:= NewGPool(100, WithMaxTasks(20))
	fmt.Println(p)
}